<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{.title}}</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 20px; }
        .container { max-width: 800px; margin: 0 auto; }
        h1 { color: #333; }
        .card { border: 1px solid #ddd; border-radius: 4px; padding: 15px; margin-bottom: 15px; }
        .btn { display: inline-block; padding: 8px 12px; background-color: #4CAF50; color: white; text-decoration: none; border-radius: 4px; cursor: pointer; }
        .btn:hover { background-color: #45a049; }
        .btn-danger { background-color: #f44336; }
        .btn-danger:hover { background-color: #d32f2f; }
        .nav { margin-bottom: 20px; }
        .nav a { margin-right: 15px; }
        .form-group { margin-bottom: 15px; }
        label { display: block; margin-bottom: 5px; }
        input { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; }
        .readonly { background-color: #f5f5f5; }
    </style>
</head>
<body>
    <div class="container">
        <div class="nav">
            <a href="/">首页</a>
            <a href="/users">用户列表</a>
            <a href="/api">网页制作</a>
        </div>
        
        <div class="card">
            <h1>{{.title}}</h1>
            <a href="/users" class="btn">返回用户列表</a>
            
            <form id="editUserForm" action="/users/update" method="post">
                <input type="hidden" name="id" value="{{.user.ID}}">
                
                <div class="form-group">
                    <label for="userId">用户ID:</label>
                    <!-- 修正name属性匹配结构体字段 -->
                    <input type="text" id="userId" name="ID" value="{{.user.ID}}" readonly class="readonly">
                </div>
                
                <div class="form-group">
                    <label for="userName">用户名:</label>
                    <!-- 修正name属性匹配结构体字段 -->
                    <input type="text" id="userName" name="Name" value="{{.user.Name}}" required>
                </div>
                
                <div class="form-group">
                    <label for="userAge">年龄:</label>
                    <!-- 修正name属性匹配结构体字段 -->
                    <input type="number" id="userAge" name="Age" value="{{.user.Age}}" required>
                </div>
                
                <button type="submit" class="btn">保存修改</button>
                <button type="button" class="btn btn-danger" onclick="cancelEdit()">取消</button>
            </form>
        </div>
        
        <div id="response" class="card" style="display: none;"></div>
    </div>
    
    <script>
        function cancelEdit() {
            window.location.href = '/users';
        }
    </script>
</body>
</html>